package com.sg.service.biz.app.nb;

import cn.hutool.core.bean.BeanUtil;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.dto.biz.app.req.CalculateAcceptAboveFieldsReqDto;
import com.sg.dto.biz.app.req.ImplementBizPublicFieldPushMemoryReqDto;
import com.sg.dto.biz.app.req.ImplementElevenReceivingFieldReqDto;
import com.sg.dto.biz.app.res.CalculateAcceptAboveFieldsRespDto;
import com.sg.dto.biz.app.res.ImplementBizPublicFieldPushMemoryRespDto;
import com.sg.dto.biz.app.res.ImplementElevenReceivingFieldRespDto;
import com.wicket.okrapp.common.baseinfo.BaseInfoDO;
import com.wicket.okrapp.common.baseinfo.BaseInfoHolder;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

/**
 * @author ： 手工接入方法
 * @version 1.0
 * @since 2022/5/28 15:32
 */
@Service
public class NbGridCalculate {
    /**
     * code:receptionService
     * name:满足循环发牌
     * desc:undefined
     * gen by moon at 5/9/2023, 5:47:43 AM
     **/
    @Trace(operationName = "满足循环发牌")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public CalculateAcceptAboveFieldsRespDto calculateAcceptAboveFields(CalculateAcceptAboveFieldsReqDto reqDto) {
        return BeanUtil.toBean(reqDto, CalculateAcceptAboveFieldsRespDto.class);
    }

    /**
     * code:publicFieldCache
     * name:M3业务应用公共字段推送内存
     * desc:undefined
     * gen by moon at 6/1/2023, 2:42:34 AM
     **/
    @Trace(operationName = "M3业务应用公共字段推送内存")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementBizPublicFieldPushMemoryRespDto implementBizPublicFieldPushMemory(ImplementBizPublicFieldPushMemoryReqDto reqDto) {
        BaseInfoDO domain = new BaseInfoDO();
        if (BaseInfoHolder.contextHolder.get() != null) {
            BeanUtil.copyProperties(BaseInfoHolder.contextHolder.get().getBaseInfo(), domain);
            BaseInfoHolder.contextHolder.remove();
        }
        if (reqDto.getSpaceId() != null) {
            domain.setSpecSpaceId(reqDto.getSpaceId());
        }

        if (reqDto.getCreateInductionId() != null) {
            domain.setSpecInductionRecordId(reqDto.getCreateInductionId());
        }

        if (reqDto.getAppId() != null) {
            domain.setSpecAppId(reqDto.getAppId());
        }

        CommonFunctionHelper.setBaseInfoToLocal(domain);
        return new ImplementBizPublicFieldPushMemoryRespDto();
    }

    /**
     * code:receptionService
     * name:M3接收上文出参字段
     * desc:undefined
     * gen by moon at 6/15/2023, 7:48:29 PM
     **/
    @Trace(operationName = "M3接收上文出参字段")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementAcceptFieldRespDto implementAcceptField(ImplementAcceptFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementAcceptFieldRespDto.class);

    }

    /**
     * code:receptionService
     * name:M3约定父中子过程周期类型
     * desc:undefined
     * gen by moon at 9/12/2024, 7:18:31 PM
     **/
    @Trace(operationName = "M3约定父中子过程周期类型")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementElevenReceivingFieldRespDto implementElevenReceivingField(ImplementElevenReceivingFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementElevenReceivingFieldRespDto.class);
    }
    //手工接入方法
}
